package cn.edu.ctbu.datajpa01.repository;

import cn.edu.ctbu.datajpa01.domain.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TeacherRepository extends JpaRepository<Teacher,Integer> {
    @Query("select t from teacher t where substring(t.ID,1,4) = "+
            "(select substring(MAX(t.ID),1,4)from teacher t group by substring(t.ID,1,4)having  count(*)>1)")
    List<Teacher> findTeacherWithSamePrefix();
}
